#include <stdio.h>

void bubble(struct stu *sh,int n);
int main()
{
	struct stu{
		int x;
		char ch[80];
		double  a,b,c;
		double average;
	};
	struct stu student[50];
	int n,i,j;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %s %lf %lf %lf",&student[i].x,student[i].ch,&student[i].a,&student[i].b,&student[i].c);
	}
	bubble(student,n);
	for(i=0;i<n;i++)
	{
		printf("%d %s %lf",student[i].x,student[i].ch,student[i].average);
	}
	return 0;
}
void bubble(struct stu *sh,int n)
{
	int i,j;
	struct stu{
		int x;
		char ch[80];
		double  a,b,c;
		double average;
	};
	struct stu temp;
	for(i=0;i<n;i++)
	{
		sh[i].average=(sh[i].a+sh[i].b+sh[i].c)/2;
	}
	for(i=0;i<n-1;i++)
	{
		for(j=0;j<n-1-i;j++)
		{
			if(sh[j].average<sh[j+1].average)
			{
				temp=sh[j];
				sh[j]=sh[j+1];
				sh[j+1]=temp;
			}
		}
	}
}
